<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
		<link rel="stylesheet" href="../static/css/xadmin.css">
		<link rel="stylesheet" href="../static/css/xadmin.css">
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="../static/lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="../static/js/xadmin.js"></script>
		<script src="../static/js/my.js"></script>
</head>
<body background="../static/images/3.jpg">
<div class="login">
    <div class="message layui-bg-orange">修改密码</div>
    <div id="darkbannerwrap"></div>

    <form class="layui-form">
        <div class="layui-form-item">
            <label for="OldPass" class="layui-form-label">
                <span class="x-red">*</span>旧密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="OldPass" name="userPwd" required="" lay-verify="OldPass" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="NewPass" class="layui-form-label">
                <span class="x-red">*</span>新密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="NewPass" name="NewPass" required="" lay-verify="NewPass" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="RePass" class="layui-form-label">
                <span class="x-red">*</span>确认密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="RePass" name="surePwd" required="" lay-verify="RePass" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="email" class="layui-form-label">
                <span class="x-red">*</span>输入邮箱地址
            </label>
            <div class="layui-input-inline">
                <input name="email" id="email"  type="text" lay-verify="email" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item">
            <label for="RePass" class="layui-form-label">
                <span class="x-red">*</span>请输入验证码
            </label>
            <div class="layui-input-inline">
                <input name="VerifyCode"   type="text"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label"></label>
            <button class="layui-btn layui-btn-radius layui-btn-warm" type="submit" lay-submit="" lay-filter="sendCode">发送验证码</button>
            <button  class="layui-btn layui-btn-radius layui-btn-warm" lay-filter="change" lay-submit="">确认修改</button>
        </div>

        <span id="i" style="color:red"></span>
    </form>
</div>
<script>
            layui.use(['form','layer'],function () {
                $ = layui.jquery;
                var form = layui.form
                    ,layer = layui.layer;
                //发送验证码
                form.on('submit(sendCode)',function (data) {
                    console.log("点击发送验证码")
                    $.ajax({
                        url:address+"/Sanyecao_Login/sendEmail",
                        type:"post",
                        data:data.field,
                        dataType:"json",//返回的数据类型
                        success:function(d){
                            //定义{info:"success"}
                            $("#e").text(d.info);
                        }
                    })
                    return false;//不让代码往下运行
                });

                //自定义验证规则
                form.verify({
                    NewPass: [/(.+){3,10}$/, '新密码必须3到10位']
                    ,RePass: function(value){
                        if($('#NewPass').val()!=$('#RePass').val()){
                            return '两次密码不一致';
                        }
                    }
                });

                //修改密码
                form.on('submit(change)', function(data){
                    if(data.field.VerifyCode==""){
                        layer.alert("邮箱验证码不能为空");
                        console.log("验证码是空的");
                        return  false;
                    }
                    $.ajax({
                        url:address+"/Sanyecao_Login/ChangePass",
                        type:"post",
                        data:data.field,
                        dataType:"json",//返回的数据类型
                        success:function(d){
                            //定义{info:"登录成功"}
                            $("#i").text(d.info);
                            //如果注册成功就跳转到登录页面
                            if(d.info=="修改密码成功"){
                                console.log(d.info);
                                alert("修改成功,点击确认返回登录界面");
                                window.location.href="login.html";
                            }
                        }
                    })
                    return false;
                });

        });

</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>
</html>


